<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //自面量形式创建对象  汽车：属性：品牌  价格  颜色  功能：跑
        var car = {
            brand: '宝马',
            price: 210000,
            color: 'red',
            run: function() {
                console.log('汽车跑起来了');
            },
            stop: function() {
                console.log('汽车停下来了');
            }
        }
        console.log(car)

        var person = {
                name: 'Cai',
                age: 19,
                sex: '女',
                hobby: function() {
                    console.log('我爱学习')
                },
                like: function() {
                    console.log('我爱吃饭');
                }
            }
            //查询  如果没有就返回undefined
        console.log(person);
        console.log(person.name)
        console.log(person.age)
        console.log(person.sex);

        person.hobby();

        //增加一个值
        person['eat'] = 'rice';
        console.log(person);

        //删除  返回结果是true删除成功或false删除失败
        var res = delete person.eat;
        console.log(person);
        console.log(res);

        //更改
        person['eat'] = 'fruit';
        console.log(person);
    </script>
</body>

</html>